package TUILayer;
import java.util.Scanner;
import ControlLayer.*;
/**
 * 
 * User interface - main menu
 * The entry-point for the application:
 * Create an instance of class MainMenuUI and the constructor starts the application
 * 
 * @author (Gruppe B) 
 * @version (1.0)
 */
public class MainMenuUI
{
    /**
    * Instance variables.
    */
    private AddressBookUI adrUI;
    private DvdUI dvdUI;
   
    /**
     * Constructor for the main UI.
     */
    public MainMenuUI()
    {
  
      
    }
   
    /**
     * Starts the main menu which gives you some options about what you can do.
     */
    public void mainMenuStart()
    {
        boolean exit=false;
        while (!exit) //! means while exit not is true (that is: false)
        {
            int choice = writeMainMenu();
            if(choice == 1)
            {
                // starts the AddressBook menu
                startAddressBook();
            }
            else
            {
                    if(choice == 2)
                    { 
                        // starts the DVD menu
                        startDvd();
                    }
                    else
                    {
                        if(choice == 3)
                        {
                            //start loanController 
                        }//end if
                        else
                        {
                            writeEnd();
                            exit = true;
                        }//end else
                    }// end else
             }//end else
        }//end while
    }//end start
    
    /**
     * Prints out the options in the menu.
     */
    private int writeMainMenu()
    {       
            // creates a keyboard object to read input
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** MainMenu ***");
            System.out.println(" (1) AddressBook");
            System.out.println(" (2) DVDs");
            System.out.println(" (3) Loan");
            System.out.println(" (4) Close");
            System.out.print("\n Make your choice: ");
            
            int choice = keyboard.nextInt();
            
            return choice;
    }
    
    /**
     * Starts the addressBook menu.
     */
    private void startAddressBook()
    {
        adrUI= new AddressBookUI();
        adrUI.start();
      
     
    }

    /**
     * Starts the DVD menu.
     */
    private void startDvd()
    {
        dvdUI= new DvdUI();
        dvdUI.start();

     
    }
    
    /**
     * Prints out an end message when closing program.
     */
    private void writeEnd()
    {
        System.out.println(" The System is shuting down ");
    }
 }
